/*
 *    Webical - http://www.webical.org
 *    Copyright (C) 2007 Func. Internet Integration
 *
 *    This file is part of Webical.
 *
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.webical.web.component.calendar;

import java.util.Calendar;
import java.util.GregorianCalendar;

import org.webical.web.action.IAction;
import org.webical.web.component.AbstractBasePanel;
import org.webical.web.component.calendar.model.DatePickerModel;

public abstract class DatePickerRowPanel extends AbstractBasePanel {
	private static final long serialVersionUID = 1L;

	@SuppressWarnings("unchecked")
	protected static Class[] PANELACTIONS = new Class[] { };

	private static String DATE_PICKER_COLUMN_REPEATER_MARKUP_ID = "datePickerColumnRepeater";

	private DatePickerModel datePickerModel;

	private GregorianCalendar currentDate;
	private GregorianCalendar weekCalendar;

	public DatePickerRowPanel(String markupId, Calendar weekCalendar, DatePickerModel datePickerModel) {
		super(markupId, DatePickerRowPanel.class);

		this.datePickerModel = datePickerModel;
		this.currentDate = new GregorianCalendar();
		this.currentDate.setTime(datePickerModel.getCurrentDate().getTime());
		this.weekCalendar = new GregorianCalendar();
		this.weekCalendar.setTime(weekCalendar.getTime());

	}

	public void setupCommonComponents() {

	}

	public void setupAccessibleComponents() {
		DatePickerColumnRepeater columnRepeater = new DatePickerColumnRepeater(DATE_PICKER_COLUMN_REPEATER_MARKUP_ID, weekCalendar, datePickerModel){
			private static final long serialVersionUID = 1L;

			@Override
			public void onAction(IAction action) {
				DatePickerRowPanel.this.onAction(action);
			}

		};
		addOrReplace(columnRepeater);
	}

	public void setupNonAccessibleComponents() {
		/* NOTHING TO DO */
	}

	/**
	 * Handle actions generated by this panel.
	 *
	 * @param action The action to handle
	 */
	public abstract void onAction(IAction action);

}
